﻿using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Terraria;
using Terraria.Localization;
using Terraria.ModLoader;

namespace EAS.Common.GlobalItems
{
    internal class TooltipMiscModify : GlobalItem
    {
        public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
        {
            if (item.accessory)
            {
                int nameIndex = tooltips.FindIndex(t => t.Name == "ItemName");
                string accessoryType = GetAccessoryType(item);
                if (accessoryType != null)
                {
                    TooltipLine line = new(Mod, "AccessoryType", $"- {accessoryType} -")
                    {
                        OverrideColor = Color.LightGreen
                    };
                    tooltips.Insert(nameIndex + 1, line);
                }
            }
        }
        private static string GetAccessoryType(Item item)
        {
            if (item.backSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.3");
            }
            if (item.balloonSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.5");
            }
            if (item.beardSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.6");
            }
            if (item.expert)
            {
                return Language.GetTextValue("Mods.EAS.Message.7");
            }
            if (item.faceSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.8");
            }
            if (item.lifeRegen > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.9");
            }
            if (item.master)
            {
                return Language.GetTextValue("Mods.EAS.Message.10");
            }
            if (item.neckSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.12");
            }
            if (item.shieldSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.13");
            }
            if (item.shoeSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.14");
            }
            if (item.waistSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.15");
            }
            if (item.wingSlot > 0)
            {
                return Language.GetTextValue("Mods.EAS.Message.16");
            }

            return null;
        }
    }
}
